﻿using Day27Auth.Adapters;
using Day27Auth.Adapters.Data;
using Day27Auth.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using Microsoft.AspNet.Identity;

namespace Day27Auth.Controllers
{
    public class TodoController : ApiController
    {
        private ITodoAdapter _adapter;

        public TodoController()
        {
            _adapter = new TodoDataAdapter();
        }

        [Authorize]
        public IHttpActionResult Get()
        {
            string userId = User.Identity.GetUserId();

            List<TodoViewModel> models = _adapter.GetTodoViewModels(userId);

            return Ok(models);
        }
    }
}
